/*
 * Mutex.c
 *
 *  Created on: 29.01.2013
 *      Author: ILYA
 */
/*
#include "Mutex.h"

void MutexInit(void)
{
	current_Cfg_task_handle = 0;
	xMutex_cfg = xSemaphoreCreateMutex();

	current_ext_flash_task_handle = 0;
	xMutex_ext_flash = xSemaphoreCreateMutex();


	current_int_flash_task_handle = 0;
	xMutex_int_flash = xSemaphoreCreateMutex();
}

void Lock_cfg(void)
{
	xSemaphoreTake( xMutex_cfg, NeverTimeout );
	current_Cfg_task_handle = xTaskGetCurrentTaskHandle();
}

int TryLock_cfg(int timeout)
{
	if(xSemaphoreTake( xMutex_cfg, (portTickType)(timeout / portTICK_RATE_MS) ) == pdTRUE)
	{
		current_Cfg_task_handle = xTaskGetCurrentTaskHandle();
		return 1;
	}
	else
	{
		current_Cfg_task_handle = 0;
		return 0;
	}
}

void UnLock_cfg(void)
{
	current_Cfg_task_handle = 0;
	xSemaphoreGive( xMutex_cfg );
}


void Lock_ext_flash(void)
{
	xSemaphoreTake( xMutex_ext_flash, NeverTimeout );
	current_ext_flash_task_handle = xTaskGetCurrentTaskHandle();
}
int TryLock_ext_flash(int timeout)
{
	if(xSemaphoreTake( xMutex_ext_flash, (portTickType)(timeout / portTICK_RATE_MS) ) == pdTRUE)
	{
		current_ext_flash_task_handle = xTaskGetCurrentTaskHandle();
		return 1;
	}
	else
	{
		current_ext_flash_task_handle = 0;
		return 0;
	}
}
void UnLock_ext_flash(void)
{
	current_ext_flash_task_handle = 0;
	xSemaphoreGive( xMutex_ext_flash );
}
void Lock_int_flash(void)
{
	xSemaphoreTake( xMutex_int_flash, NeverTimeout );
	current_int_flash_task_handle = xTaskGetCurrentTaskHandle();
}
int TryLock_int_flash(int timeout)
{
	if(xSemaphoreTake( xMutex_int_flash, (portTickType)(timeout / portTICK_RATE_MS) ) == pdTRUE)
	{
		current_int_flash_task_handle = xTaskGetCurrentTaskHandle();
		return 1;
	}
	else
	{
		current_int_flash_task_handle = 0;
		return 0;
	}
}
void UnLock_int_flash(void)
{
	current_int_flash_task_handle = 0;
	xSemaphoreGive( xMutex_int_flash );
}
*/
